home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 1996 May / cd joy 71No13.iso / pc / demos / eurosoc / source / euro_cnt.cpp < prev    next >
C/C++ Source or Header  |  1996-03-19  |  4KB  |  184 lines

  1. #include <i86.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5. #include <conio.h>
  6.  
  7. #include "eurodefs.h"
  8. #include "euro_fxd.h"
  9. #include "euro.equ"
  10. #include "euro_sym.h"
  11. #include "euro_def.h"
  12. #include "euro_var.h"
  13. #include "euro_grf.h"
  14. #include "euro_dsk.h"
  15. #include "euro_fix.h"
  16. #include "euro_sel.h"
  17. #include "euro_inf.h"
  18.  
  19. #include "defines.h"
  20.  
  21. //********************************************************************************************************************************
  22.  
  23. char    InitialiseUser( char user, char cntrl )
  24.     {
  25.         if ( EUROgameType == EURO_friendly )
  26.         {
  27.             UserList[user].control = cntrl;
  28.             user++;
  29.         }
  30.  
  31.         if ( EUROgameType == EURO_championship )
  32.         {
  33.             UserList[user].control = cntrl;
  34.             user++;
  35.         }
  36.  
  37.  
  38.             
  39.         if ( (EUROgameType == EURO_network_game || EUROgameType == EURO_wireplay )
  40.             && user==0 )
  41.         {
  42.             UserList[user].control = cntrl;
  43.             user    =    1;
  44.         }
  45.  
  46.     return(user);
  47.     }
  48.  
  49. //********************************************************************************************************************************
  50.  
  51. char    CalculateMaxPlayers()
  52.     {
  53.         char    players    =    0;
  54.  
  55.         for ( char p=0; p<16 ; p++ )
  56.         {
  57.             if (CtrlFlags[p] == Usable)
  58.                 players++;        
  59.         }
  60.  
  61.         return(players);
  62.     }
  63.  
  64. //********************************************************************************************************************************
  65.  
  66. void    SetupMouseLimits( int Xmin, int Xmax, int Ymin, int Ymax )
  67.     {
  68.         if ( MouseDriverInstalled != 0 )
  69.         {
  70.             union REGS rg;
  71.             rg.x.ecx = Xmin;
  72.             rg.x.edx = Xmax;
  73.             rg.x.eax = 7;
  74.             int386(0x33,&rg,&rg);
  75.             rg.x.ecx = Ymin;
  76.             rg.x.edx = Ymax;
  77.             rg.x.eax = 8;
  78.             int386(0x33,&rg,&rg);
  79.         }
  80.     }
  81.  
  82. //********************************************************************************************************************************
  83.  
  84. char    SetupControlMethods()
  85.     {
  86.         for ( char m=0; m<16 ; m++ )
  87.         {CtrlFlags[m]    =    Unusable;}    
  88.  
  89.         char    user = 0;
  90.  
  91. // ***> Configure KEYBOARD 1        
  92.  
  93.             CtrlFlags[EuroKeyboard1] = Usable;
  94.             user = InitialiseUser( user, EuroKeyboard1 );                  
  95.             
  96.             if (EUROverbose)
  97.                 printf    ("˛ Keyboard 1 initialised.\n");
  98.  
  99. // ***> Configure KEYBOARD 2
  100.  
  101.             CtrlFlags[EuroKeyboard2] = Usable;
  102.             user = InitialiseUser( user, EuroKeyboard2 );                  
  103.  
  104.             if (EUROverbose)
  105.                 printf    ("˛ Keyboard 2 initialised.\n");
  106.  
  107. // ***> Configure JOYSTICK 1
  108.         
  109. //            CtrlFlags[EuroJoystick1] = Usable;
  110. //            user = InitialiseUser( user, EuroJoystick1 );                  
  111. //
  112. //            if (EUROverbose)
  113. //                printf    ("˛ Joystick 1 initialised.\n");
  114. //
  115. // ***> Configure JOYSTICK 2
  116.  
  117.  
  118.  
  119. // ***> Configure MOUSE
  120.     
  121.         union REGS rg;
  122.         rg.x.eax = 0;
  123.         int386(0x33,&rg,&rg);
  124.  
  125.         if ( (MouseDriverInstalled = rg.h.al) != 0 )
  126.         {
  127.             CtrlFlags[EuroMouse] = Usable;
  128.             SetupMouseLimits( 0, 626, 1, 452 );
  129.             user = InitialiseUser( user, EuroMouse);                  
  130.         }
  131.  
  132.         if ( MouseDriverInstalled == 0 )
  133.         {
  134.             if (EUROverbose)
  135.                 printf    ("˛ Mouse Driver not found.\n");
  136.         }
  137.         else
  138.         {
  139.             if (EUROverbose)
  140.                 printf    ("˛ Mouse Driver found and initialised.\n");
  141.         }
  142.  
  143. // ***> Configure LOGITECH PAD
  144.  
  145.         return    ( CalculateMaxPlayers() );
  146.     }
  147.  
  148. //********************************************************************************************************************************
  149.  
  150. float     WhichButton(short button, float var )
  151.     {
  152.         if ( button == LEFT_BUTTON )
  153.             return(-var);
  154.         else
  155.             return(var);
  156.     }
  157.  
  158. //********************************************************************************************************************************
  159.  
  160. void    GetConsoleInput()
  161.     {
  162.         if ( MouseDriverInstalled != 0 )
  163.         {
  164.             short    buttons;
  165.             union REGS inregs, outregs;
  166.             inregs.w.ax = 3;
  167.             int386(0x33, &inregs, &outregs);
  168.             SelectorXcoord    =    outregs.w.cx;
  169.             SelectorYcoord    =    outregs.w.dx;
  170.             buttons        =    outregs.w.bx;
  171.             
  172.             if ( DeBounce == 0 )
  173.                 ButtonState = buttons;
  174.             else
  175.             {
  176.                 ButtonState = 0;
  177.                 if ( buttons == 0 )
  178.                     DeBounce = 0;                
  179.             }
  180.         }
  181.     }
  182.  
  183. //********************************************************************************************************************************
  184.